//
//  VC_Comment.m
//  yjw-winner
//
//  Created by 隆霁 on 2018/9/26.
//  Copyright © 2018年 Shanghai decade financial information service co., LTD. All rights reserved.
//

#import "VC_Comment.h"

static const NSString *TextViewTextContext;
@interface VC_Comment () {
    
}
@property (weak, nonatomic) IBOutlet UITextView *textView;
@property (nonatomic, strong) UIButton *sendButton;
@end

@implementation VC_Comment
- (UIButton *)sendButton {
    if (!_sendButton) {
        _sendButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sendButton setImage:[UIImage imageNamed:@"un_comment_send_able"] forState:UIControlStateNormal];
        [_sendButton setImage:[UIImage imageNamed:@"un_comment_send_enable"] forState:UIControlStateDisabled];
        _sendButton.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 15 - 45, 10, 50, 24);
        _sendButton.enabled = NO;
        [_sendButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _sendButton;
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar addSubview:self.sendButton];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.sendButton removeFromSuperview];
}
- (instancetype)init {
    if (self = [super init]) {
        self = [[UIStoryboard storyboardWithName:@"CourseListStoryBoard" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:NSStringFromClass([VC_Comment class])];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:UITextViewTextDidChangeNotification object:self.textView];

}

- (void)textDidChange:(UITextView *)text {
    _sendButton.enabled = (self.textView.text.length > 0) ? YES : NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark --mark EVENT
- (void)buttonClick:(UIButton *)sender {
    // 提交回复
    //
}
@end
